{% extends "layout.html" %}

{% block header -%}
{{ super() }}
<hr/>

<script language="javascript">
  /**
   * A simple HTML iframe string.
   * @param {String} attributes A set of HTML attributes for the table.
   * @param {String} url The source of the iframe.
   * @returns {!String} the iframe or an empty string if noframe is specified.
   */
  function iFrame(attributes, url) {
    if (window.location.href.search('noframe') == -1) {
      return '<iframe ' + attributes + ' src="' + url + '"></iframe>';
    }
    return ''
  };

  /**
   * Callback to replace the LKGR link with one that identifies the current
   * revision for the LKGR.
   */
  function DisplayLKGR() {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.onreadystatechange = function() { 
      if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        lkgr_entry = JSON.parse(xmlHttp.responseText)[0];
        git_hash = lkgr_entry['git_hash'].substring(0, 8);
        lkgr_date = lkgr_entry['date']
        if (!/ UTC$/.test(lkgr_date) && ! / GMT$/.test(lkgr_date))
          // The lkgr date is in UTC, but it's unfortunately not part of the
          // string. Add it as otherwise the parser assumes local time.
          lkgr_date += ' UTC'
        now = (new Date()).getTime();
        lkgr_date = Date.parse(lkgr_date);
        age_in_hours = (now - lkgr_date) / 3600000;
        new_label = git_hash + ' (' + Math.floor(age_in_hours) + 'h old)';
        document.getElementById('lkgr_link').innerHTML = new_label;
      }
    };

    var lkgrPath = "https://v8-status.appspot.com/commits?format=json";
    xmlHttp.open('GET', lkgrPath, true);
    xmlHttp.send(null);
  }

  branches_url = "https://build.chromium.org/p/client.v8.branches/horizontal_one_box_per_builder"
  fyi_url = "https://build.chromium.org/p/client.v8.fyi/horizontal_one_box_per_builder"
</script>

<div class="Announcement">

<iframe width="100%" height="44" frameborder="0" scrolling="no" src="https://v8-status.appspot.com/current" ></iframe>

<center style="padding: 0 7px">
  <table width="100%" valign="top" bgcolor="#efefef" style="border-bottom-left-radius: 24px; border-bottom-right-radius: 24px; box-shadow: 2px 2px 6px rgba(0,0,0,0.6);">
    <tr>
      <td width="1%" />
      <td width="40%" style="text-align: left;">
        <table width="100%" valign="top">
          <tr>
            <td width="8%" style="text-align: left;">
              <b>Sheriffs: </b>
            </td>
            <td width="52%" style="text-align: left;">
              <script src='https://chromium-build.appspot.com/p/chromium/sheriff_v8.js'></script>
            </td>
            <td width="8%" style="text-align: left;">
              <b>Controls: </b>
            </td>
            <td width="32%" style="text-align: left;">
              <a id="tree_status_link" href="https://v8-status.appspot.com">
                tree status
              </a> |
              <a id="roll_status_link" href="https://v8-roll.appspot.com">
                roll status
              </a>
            </td>
          </tr>
          <tr>
            <td width="8%" style="text-align: left;">
              <b>Masters: </b>
            </td>
            <td width="52%" style="text-align: left;">
              <a id="master_v8" href="../client.v8">
                client.v8
              </a> |
              <a id="master_v8_fyi" href="../client.v8.fyi">
                client.v8.fyi
              </a> |
              <a id="master_v8_branches" href="../client.v8.branches">
                client.v8.branches
              </a>
            </td>
            <td width="8%" style="text-align: left;">
              <b>LKGR: </b>
            </td>
            <td width="32%" style="text-align: left;">
              <a id="lkgr_link" href="https://v8-status.appspot.com/commits">
                lkgr
              </a>
              <script language="javascript">
                setTimeout('DisplayLKGR()', 100);
              </script>
            </td>
          </tr>
        </table>  
      </td>
      <td width="58%" style="text-align: left;">
        <table valign="top" width="100%" style="text-align: left;">
          <tr>
            <td width="5%">
              <a id="master_v8_fyi_label" href="../client.v8.fyi">
                <b>FYI: </b>
              </a>
            </td>
            <td width="95%">
              <script language="javascript">
                iframe_properties = [
                  'width="100%"',
                  'height="15"',
                  'frameborder="0"',
                  'scrolling="no"',
                ].join(' ');
                document.write(iFrame(iframe_properties, fyi_url))
              </script>
            </td>
          </tr>
          <tr>
            <td width="5%">
              <a id="master_v8_branches_label" href="../client.v8.branches">
                <b>Branches: </b>
              </a>
            </td>
            <td width="95%">
              <script language="javascript">
                iframe_properties = [
                  'width="100%"',
                  'height="15"',
                  'frameborder="0"',
                  'scrolling="no"',
                ].join(' ');
                document.write(iFrame(iframe_properties, branches_url))
              </script>
            </td>
          </tr>
        </table>  
      </td>
      <td width="1%" />
    </tr>
  </table>
</center>

</div>
{% endblock header %}

{% block footer %}

{{ super() }}
{# <p>Debug info: {{ debuginfo }}</p> #}
{% endblock %}
